package day20.pack2;

public class Counter {
    private int count;
    private final static Object lock1 = new Object();
    private final static Object lock2 = new Object();

    public void increment() {
        synchronized (lock1) {
            synchronized (lock2) {
                System.out.println("执行count++");
                count++;
            }
        }
    }
    public void decrement() {
        synchronized (lock2) {
            synchronized (lock1) {
                System.out.println("执行count--");
                count--;
            }
        }
    }
}
